<template>
  <div class="fillcontain">
    <bt-col-header title="任务管理"></bt-col-header>
    <!-- 查询表单 -->
    <div class="page-content">
      <el-form :model="searchParams" ref="ruleForm" label-width="120px" class="">
        <div class="row">
          <div class="col-md-4">
            <el-form-item label="需求编码" prop="demandNo">
              <el-input clearable v-model="searchParams.demandNo" placeholder="需求编码"></el-input>
            </el-form-item>
          </div>
          <div class="col-md-4">
            <el-form-item label="需求描述" prop="demandDesc">
              <el-input clearable v-model="searchParams.demandDesc" placeholder="需求描述"></el-input>
            </el-form-item>
          </div>
          <div class="col-md-4">
            <el-form-item label="任务状态" prop="status">
              <el-select clearable v-model="searchParams.status" filterable placeholder="请选择">
                <el-option v-for="item in status" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </div>
        </div>
        <div class="row contain-padding">
          <div class="col-md-12 text-center mt-2">
            <rich-button type="info" plain shape="capsule" icon="search" @click="search">查询</rich-button>
            <rich-button shape="capsule" icon="quit" @click="resetSearch()">重置</rich-button>
          </div>
        </div>
      </el-form>

      <div class="">
        <!-- 操作按钮 -->
        <div class="btn-padding left">
          <el-button type="info" plain icon="circle-plus" @click="addTask('新增')">新增</el-button>
          <el-button type="info" plain icon="rect-uparrow" @click="fabu()">发布</el-button>
        </div>

        <!-- 查询结果列表 -->
        <div class="table_container">
          <el-table ref="multipleTable" v-loading="loading" :data="tableData" tooltip-effect="dark" highlight-current-row header-cell-class-name="table-header-class" empty-text="无符合查询条件任务" style="width: 100%" @selection-change="handleSelectionChange" :row-class-name="tableRowClassName">
            <el-table-column type="selection"></el-table-column>
            <el-table-column property="taskNo" sortable label="任务编码" align="center" show-overflow-tooltip min-width="80"></el-table-column>
            <!-- <el-table-column property="taskNo" label="任务编码" align='center' show-overflow-tooltip
                            min-width="80"></el-table-column> -->
            <el-table-column property="demandNo" label="需求号码" align="center" show-overflow-tooltip min-width="80"></el-table-column>
            <el-table-column property="demandName" label="需求名称" align="center" show-overflow-tooltip min-width="100"></el-table-column>
            <el-table-column property="taskStartTime" sortable label="任务开始时间" align="center" show-overflow-tooltip min-width="160">
              <!-- <template slot-scope="scope">
              <span :class="scope.row.startcolor ? 'colorred' : ''">{{ scope.row.taskStartTime}}</span>
              </template> -->
            </el-table-column>
            <el-table-column property="taskEndTime" label="任务结束时间" align="center" show-overflow-tooltip min-width="160">
              <!-- <template slot-scope="scope">
              <span :class="scope.row.endcolor ? 'colorred' : ''">{{ scope.row.taskEndTime}}</span>
              </template> -->
            </el-table-column>
            <el-table-column property="demandDesc" label="任务描述" align="center" show-overflow-tooltip min-width="100"></el-table-column>
            <el-table-column property="status" label="任务状态" align="center" show-overflow-tooltip min-width="140">
              <template slot-scope="scope">
                {{ scope.row.status | statusFormat }}
              </template>
            </el-table-column>
            <el-table-column property="taskLevel" label="任务优先级" align="center" show-overflow-tooltip min-width="80">
              <template slot-scope="scope">
                {{ scope.row.taskLevel | taskLevelFormat }}
              </template>
            </el-table-column>
            <el-table-column property="flawUpdate" label="是否修改流程" align="center" show-overflow-tooltip min-width="100">
              <template slot-scope="scope">
                {{ scope.row.flawUpdate | flagFormat }}
              </template>
            </el-table-column>
            <el-table-column property="addColumn" label="是否添加列" align="center" show-overflow-tooltip min-width="100">
              <template slot-scope="scope">
                {{ scope.row.addColumn | flagFormat }}
              </template>
            </el-table-column>
            <el-table-column property="isClashStatus" label="是否存在冲突" align="center" show-overflow-tooltip min-width="100">
              <template slot-scope="scope">
                {{ scope.row.isClashStatus | isClashFormat }}
              </template>
            </el-table-column>
            <!-- 规划 -->
            <!-- <el-table-column property="clashTask" label="冲突版本" align="center" show-overflow-tooltip min-width="100"></el-table-column> -->
            <el-table-column property="auditStatus" label="审核状态" align="center" show-overflow-tooltip min-width="100">
              <template slot-scope="scope">
                <div v-if="scope.row.status == '4'">
                  {{ scope.row.auditStatus | auditStatusFormat }}
                </div>
                <div v-else>--</div>
              </template>
            </el-table-column>
            <el-table-column property="" label="操作" align="center" show-overflow-tooltip width="260">
              <template slot-scope="scope">
                <el-tooltip class="item" effect="dark" content="编辑" placement="top">
                  <el-button type="text" @click="showTask(scope.row)" >
                    <icon-svg :name="'edit'"></icon-svg>
                  </el-button>
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="删除" placement="top">
                  <el-button type="text" @click="deleteTask(scope.row)">
                    <!-- 删除 -->
                    <icon-svg :name="'delete'"></icon-svg>
                  </el-button>
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="查看" placement="top">
                  <el-button type="text" @click="showDetail(scope.row)">
                    <!-- 查看 -->
                    <icon-svg :name="'look'"></icon-svg>
                  </el-button>
                </el-tooltip>
                <!-- -->
                <el-tooltip class="item" effect="dark" content="冲突" placement="top">
                  <el-button v-if="scope.row.isClashStatus == 'Y'" type="text" @click="getConfirmClash(scope.row)">
                    <!-- 冲突 -->
                    <icon-svg :name="'send'"></icon-svg>
                  </el-button>
                </el-tooltip>
                <!-- 发布 -->
                <el-tooltip class="item" effect="dark" content="发布" placement="top" v-if="
                      scope.row.isClashStatus == 'N' &&
                      scope.row.status != '4' &&
                      scope.row.status != '8' &&
                      scope.row.status != '9'
                    ">
                  <el-button v-if="
                      scope.row.isClashStatus == 'N' &&
                      scope.row.status != '4' &&
                      scope.row.status != '8' &&
                      scope.row.status != '9'
                    " type="text" size="small" @click="publish(scope.row)">
                    <icon-svg :name="'send1'"></icon-svg>
                  </el-button>
                </el-tooltip>
                <!-- 已发布测试 ，（审核通过）-->
                <el-tooltip class="item" effect="dark" content="发布测试" placement="top">
                  <el-button v-if="
                      scope.row.isClashStatus == 'N' &&
                      scope.row.status == '4' &&
                      scope.row.auditStatus == '2'
                    " type="text" size="small" @click="publish(scope.row)">
                    <icon-svg :name="'send1'"></icon-svg>
                  </el-button>
                </el-tooltip>
                <!-- 审核 -->
                <el-tooltip class="item" effect="dark" content="审核" placement="top">
                  <el-button v-if="
                      scope.row.status == '4' &&
                      scope.row.auditStatus != '1' &&
                      scope.row.auditStatus !== '2'
                    " type="text" size="small" @click="audit(scope.row)">
                    <icon-svg :name="'shenhe'"></icon-svg>
                  </el-button>
                </el-tooltip>
                <!-- 测试 -->
                <el-tooltip class="item" effect="dark" content="测试" placement="top">
                  <el-button v-if="
                      scope.row.status == '4' &&
                      scope.row.auditStatus != '2' &&
                      scope.row.auditStatus != '1'
                    " type="text" size="small" @click="ceshi(scope.row)">
                    <icon-svg :name="'ceshi'"></icon-svg>
                  </el-button>
                </el-tooltip>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <!-- 分页 -->
        <div class="">
          <el-pagination class="float-right mt-2" @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page.sync="paginations.pageIndex" :page-sizes="[10, 20, 50, 100]" :page-size="paginations.pageSize" :total="paginations.total" layout="total, sizes, prev, pager, next, jumper">
          </el-pagination>
        </div>
        <el-dialog :title="`${dialogTitle}任务`" :visible.sync="addVisible" width="60%" center>
          <el-form :model="task" :rules="dataRule" ref="nodeForm" @keyup.enter.native="saveTask()" status-icon label-width="120px">
            <el-row>
              <el-col :span="12">
                <el-form-item label="任务编码">
                  <el-input clearable v-model="task.taskNo" placeholder="任务编码" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="需求号码" prop="demandNo">
                  <el-input clearable v-model="task.demandNo" placeholder="需求号码"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="需求名称" prop="demandName">
                  <el-input clearable v-model="task.demandName" placeholder="需求名称"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="任务开始时间" prop="taskStartTime">
                  <el-date-picker type="date" :format="'yyyy-MM-dd'" clearable v-model="task.taskStartTime" placeholder="任务开始时间" :editable="false"></el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="任务结束时间" prop="taskEndTime">
                  <el-date-picker type="date" :format="'yyyy-MM-dd'" clearable v-model="task.taskEndTime" placeholder="任务结束时间" :editable="false"></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="任务优先级" prop="taskLevel">
                  <el-select clearable v-model="task.taskLevel" filterable placeholder="请选择">
                    <el-option v-for="item in taskLevel" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <!-- <el-row>
            <el-col :span="6">
            <el-form-item label="是否修改流程" prop="flawUpdate">
              <el-select clearable v-model="task.flawUpdate" filterable placeholder="请选择">
                <el-option
                  v-for="item in flag"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          </el-row> -->
            <el-col :span="24">
              <el-form-item label="任务描述" prop="demandDesc">
                <el-input type="textarea" :rows="4" clearable v-model="task.demandDesc" placeholder="任务描述"></el-input>
              </el-form-item>
            </el-col>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="getaddVisible()">取 消</el-button>
            <el-button type="primary" @click="saveTask">保 存</el-button>
          </div>
        </el-dialog>
      </div>  
    </div>
    
  </div>
</template>

<script>
import {
  taskPage,
  taskSave,
  deleteTask,
  taskUpdate,
  checkClash,
  saveAudit,
  publishTask,
  testStatus,
  confirmClash,
} from "@/api/version/version";
import constant from "@/api/constant";
import taskDialog from "./tasklist-dialog";
export default {
  components: {},
  data() {
    return {
      //       // 开始时间小于结束时间，且开始时间小于此刻
      //       startTime: {
      //         disabledDate: time => {
      //           if (this.task.taskEndTime) {
      //             return time.getTime() > new Date(this.task.taskEndTime).getTime()
      //           }
      //         }
      //       },
      // // 结束时间大于开始时间，且小于此刻
      //       endTime: {
      //         disabledDate: time => {
      //           if (this.task.taskStartTime) {
      //             return  time.getTime() < new Date(this.task.taskStartTime).getTime()
      //           }
      //         }
      //       },
      multipleSelection: [],
      taskDetail: {},
      tabDialog: 1,
      ruleInfoClashVoList: [],
      ruleInfoVoList: [],
      dialogTitle: "",
      loading: false,
      tableData: [],
      searchParams: {
        // 需求编码
        demandNo: "",
        // 需求描述
        demandDesc: "",
        status: "",
        pageSize: "",
        pageNumber: "",
      },
      task: {
        taskNo: "",
        demandDesc: "",
        demandNo: "",
        taskLevel: "1",
        demandName: "",
        flawUpdate: "0",
        taskEndTime: "",
        taskStartTime: "",
      },
      status: constant.status,
      flag: constant.flag,
      taskLevel: constant.taskLevel,
      addVisible: false,
      clashVisible: false,
      addFlag: true,
      paginations: {
        total: 0, // 总数
        pageIndex: 1, // 当前位于哪页
        pageSize: 20, // 1页显示多少条
      },
      dataRule: {
        taskNo: [
          { required: true, message: "任务编号不能为空", trigger: "blur" },
        ],
        demandDesc: [
          { required: true, message: "任务描述不能为空", trigger: "blur" },
        ],
        demandNo: [
          { required: true, message: "需求号码不能为空", trigger: "blur" },
        ],
        demandName: [
          { required: true, message: "需求名称不能为空", trigger: "blur" },
        ],
        taskStartTime: [
          { required: true, message: "任务开始时间不能为空", trigger: "blur" },
        ],
        taskEndTime: [
          { required: true, message: "任务结束时间不能为空", trigger: "blur" },
        ],
        taskLevel: [
          { required: true, message: "任务级别不能为空", trigger: "blur" },
        ],
      },
      taskInfo: {},
      groupInfoList: [],
      flowList: [],
    };
  },
  created() {
    this.getList();
  },
  activated() {
    // this.getList()
  },
  components: {
    taskDialog,
  },
  mounted() { },
  methods: {
    getaddVisible() {
      this.addVisible = false;
      this.$refs.nodeForm.resetFields();
    },
    // addVisible = false
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    tableRowClassName(row, rowIndex) {
      if (row.endcolor) {
        return "colorred";
      } else {
        return "";
      }
      return "";
    },
    // 流程修改
    editFlow(val) { },
    // 规则组解决冲突
    viewguize(val) {
      this.tabDialog = 2;
    },
    showDetail(data) {
      this.$router.push({ path: "/drools-version/view-task/" + data.taskNo });
    },
    search() {
      // this.paginations.pageIndex = 1;
      this.getList();
    },
    showTask(data) {
      this.dialogTitle = "编辑";
      this.addVisible = true;
      this.task = JSON.parse(JSON.stringify(data));
      this.addFlag = false;
    },
    getList() {
      this.paginations.total = 0;
      this.tableData = [];
      this.$store.dispatch("loading/CHANGE_LOADING", true);
      this.searchParams.pageNumber = this.paginations.pageIndex;
      this.searchParams.pageSize = this.paginations.pageSize;
      let that = this;
      taskPage(this.searchParams)
        .then((res) => {
          this.$store.dispatch("loading/CHANGE_LOADING", false);
          that.paginations.pageIndex = res.data.data.currPage;
          if (
            res.data.resultCode == 0 &&
            res.data.data &&
            res.data.data.list.length
          ) {
            let date = new Date();

            date = constant.dateFormat("YYYY-mm-dd", date);
            that.paginations.total = res.data.data.totalCount;
            res.data.data.list.forEach((e) => {
              e.taskStartTime = constant.dateFormat(
                "YYYY-mm-dd",
                e.taskStartTime
              );
              e.taskEndTime = constant.dateFormat("YYYY-mm-dd", e.taskEndTime);
              if (
                new Date(e.taskEndTime).getTime() < new Date(date).getTime()
              ) {
                e.endcolor = "red";
              } else {
                e.endcolor = "";
              }
            });

            // })
            this.tableData = res.data.data.list;
          }
        })
        .catch((err) => {
          this.$store.dispatch("loading/CHANGE_LOADING", false);
        });
    },
    addTask() {
      this.dialogTitle = "新增";
      this.addVisible = true;
      this.addFlag = true;
      this.task = this.$options.data().task;
    },
    saveTask() {
      this.task.taskStartTime && (this.task.taskStartTime = constant.dateFormat(
        "YYYY-mm-dd",
        this.task.taskStartTime
      ))
      this.task.taskEndTime && (this.task.taskEndTime = constant.dateFormat(
        "YYYY-mm-dd",
        this.task.taskEndTime
      ))
      if (this.task.taskStartTime > this.task.taskEndTime) {
        // this.$refs.nodeForm.validateField("taskStartTime");
        this.$message({
          message: `任务开始时间不能超过任务结束时间！`,
          type: "warning",
          duration: 1500,
          onClose: () => { },
        });
        return;
      }
      this.$refs["nodeForm"].validate((valid) => {
        if (valid) {
          this.$store.dispatch("loading/CHANGE_LOADING", true);
          if (this.addFlag) {
            this.task.taskStartTime = constant.dateFormat(
              "YYYY-mm-dd",
              this.task.taskStartTime
            );
            this.task.taskEndTime = constant.dateFormat(
              "YYYY-mm-dd",
              this.task.taskEndTime
            );
            taskSave(this.task)
              .then((res) => {
                this.$store.dispatch("loading/CHANGE_LOADING", false);
                if (res.data.resultCode == constant.SUCCESS) {
                  // this.task
                  this.$message({
                    message: "操作成功",
                    type: "success",
                    duration: 1500,
                    onClose: () => {
                      this.addVisible = false;
                    },
                  });
                  this.getList();
                } else {
                  this.$message({
                    message: res.data.resultMsg,
                    type: "error",
                    duration: 1500,
                    onClose: () => {
                      this.addVisible = false;
                    },
                  });
                }
              })
              .catch((err) => {
                this.$store.dispatch("loading/CHANGE_LOADING", false);
              });
          } else {
            taskUpdate(this.task)
              .then((res) => {
                this.$store.dispatch("loading/CHANGE_LOADING", false);
                if (res.data.resultCode == constant.SUCCESS) {
                  this.$message({
                    message: "操作成功",
                    type: "success",
                    duration: 1500,
                    onClose: () => {
                      this.addVisible = false;
                    },
                  });
                  this.getList();
                } else {
                  this.$message({
                    message: res.data.resultMsg,
                    type: "error",
                    duration: 1500,
                    onClose: () => {
                      this.addVisible = false;
                    },
                  });
                }
              })
              .catch((err) => {
                this.$store.dispatch("loading/CHANGE_LOADING", false);
              });
          }
        }
      });
    },
    deleteTask(data) {
      this.$confirm(`确定将该任务删除?`, "温馨提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$store.dispatch("loading/CHANGE_LOADING", true);
          deleteTask(data)
            .then((res) => {
              this.$store.dispatch("loading/CHANGE_LOADING", false);
              if (res.data.resultCode == constant.SUCCESS) {
                this.$message({
                  message: res.data.resultMsg,
                  type: "success",
                  duration: 1500,
                  onClose: () => {
                    this.addVisible = false;
                  },
                });
                this.getList();
              } else {
                this.$message({
                  message: res.data.resultMsg,
                  type: "error",
                  duration: 1500,
                  onClose: () => {
                    this.addVisible = false;
                  },
                });
              }
            })
            .catch((err) => {
              this.$store.dispatch("loading/CHANGE_LOADING", false);
            });
        })
        .catch(() => { });
    },
    // 发布
    publish(row) {
      let msg;
      if (row.status == "1") {
        msg = "确定该任务发布到待发布测试环境？";
      } else if (row.status == "2") {
        msg = "确定将该任务提交审核？";
      } else if (row.status == "3") {
        msg = "确定将该任务发布到测试环境？";
      } else if (row.status == "4") {
        if (row.auditStatus == "2") {
          msg = "确定将该任务发布到预生产环境？";
        } else {
          msg = "是否已经发布到测试环境？";
        }
      } else if (row.status == "5") {
        msg = "确定将该任务发布到预生产环境？";
      } else if (row.status == "6") {
        msg = "是否已经发布预生产环境？";
      } else if (row.status == "7") {
        msg = "确定将该任务发布到生产环境？";
      } else if (row.status == "8") {
        msg = "是否已经发布生产环境？";
      }
      let param = {
        taskNo: row.taskNo,
        status: row.status,
      };
      this.$confirm(msg, "温馨提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.getTaskData([param], row);
        })
        .catch(() => { });
    },
    ceshi(row) {
      this.$confirm(`该任务测试不通过？`, "温馨提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          // row.auditStatus = '1'
          let param = {
            taskNo: row.taskNo,
          };
          this.getceshi(param);
        })
        .catch(() => { });
    },
    getceshi(param) {
      this.$store.dispatch("loading/CHANGE_LOADING", true);
      testStatus(param)
        .then((res) => {
          this.$store.dispatch("loading/CHANGE_LOADING", false);
          if (res.data.resultCode == constant.SUCCESS) {
            this.$message({
              message: res.data.resultMsg,
              type: "success",
              duration: 1500,
              onClose: () => {
                this.getList();
              },
            });
          } else {
            this.$store.dispatch("loading/CHANGE_LOADING", false);
            this.$message({
              message: `发布失败！`,
              type: "error",
              duration: 1500,
              onClose: () => { },
            });
          }
        })
        .catch((err) => {
          this.$store.dispatch("loading/CHANGE_LOADING", false);
        });
    },
    // 选择发布
    fabu() {
      if (!this.multipleSelection.length) {
        this.$message({
          message: `请选择任务再发布！`,
          type: "warning",
          duration: 1500,
          onClose: () => { },
        });
        return;
      }
      let isfabu = true;
      this.multipleSelection.forEach((e) => {
        if (e.isClashStatus == "Y") {
          this.$message({
            message: `选择的任务中有任务存在冲突，需解决完冲突才能发布！`,
            type: "warning",
            duration: 1500,
            onClose: () => { },
          });
          isfabu = false;
          return;
        } else if (e.status == "4" && e.auditStatus != "2") {
          this.$message({
            message: `选择的任务中有任务未通过审核，需审核通过才能发布！`,
            type: "warning",
            duration: 1500,
            onClose: () => { },
          });
          isfabu = false;
          return;
        } else if (e.status == "8") {
          this.$message({
            message: `选择的任务中任务已发布生产环境，已发布生产环境任务不需要再发布！`,
            type: "warning",
            duration: 1500,
            onClose: () => { },
          });
          isfabu = false;
          return;
        } else if (e.status == "9") {
          this.$message({
            message: `选择的任务中任务状态有结束任务，结束任务不需要发布！`,
            type: "warning",
            duration: 1500,
            onClose: () => { },
          });
          isfabu = false;
          return;
        }
      });
      if (isfabu) {
        let param = [];
        this.multipleSelection.forEach((e, i) => {
          param[i] = { taskNo: e.taskNo, status: e.status };
        });
        this.getTaskData(param);
      }
    },
    getTaskData(param) {
      this.$store.dispatch("loading/CHANGE_LOADING", true);
      publishTask(param)
        .then((res) => {
          if (res.data && res.data.data) {
            let data = res.data.data;
            let type = "success";
            if (data.findIndex((target) => target.resultCode != 0) == -1) {
              // 全部发布成功
              type = `success`;
            } else if (
              data.findIndex((target) => target.resultCode === 0) == -1
            ) {
              // 全部发布失败
              type = `error`;
            } else {
              type = `warning`;
            }
            let msg = "";
            data.forEach((e) => {
              msg += e.resultMsg;
            });
            this.$store.dispatch("loading/CHANGE_LOADING", false);
            this.$message({
              message: msg,
              type: type,
              duration: 1500,
              onClose: () => {
                this.getList();
              },
            });
          } else {
            this.$store.dispatch("loading/CHANGE_LOADING", false);
            this.$message({
              message: `发布失败！`,
              type: "error",
              duration: 1500,
              onClose: () => { },
            });
          }
        })
        .catch((err) => {
          this.$store.dispatch("loading/CHANGE_LOADING", false);
          this.$message({
            message: `发布失败！`,
            type: "error",
            duration: 1500,
            onClose: () => { },
          });
        });
    },
    getConfirmClash(row) {
      if (row.isClashStatus == "Y" && row.status == "1") {
        let params = {
          taskNo: row.taskNo,
        };
        this.$store.dispatch("loading/CHANGE_LOADING", true);
        confirmClash(params)
          .then((res) => {
            this.$store.dispatch("loading/CHANGE_LOADING", false);
            if (res.data.data) {
              this.$confirm(
                `该任务有冲突需求，请合并解决冲突需求才能审核?`,
                "温馨提示",
                {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
                }
              )
                .then(() => {
                  this.$router.push({
                    path: "/drools-version/conflict-resolve/" + row.taskNo,
                  });
                })
                .catch(() => { });
            } else {
              this.$confirm(`该任务没有冲突需求！`, "温馨提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              })
                .then(() => { })
                .catch(() => { });
            }
          })
          .catch((err) => { });
      }
    },
    // 审核
    audit(row) {
      let param = {
        taskNo: row.taskNo,
      };
      saveAudit(param)
        .then((res) => {
          if (res.data.resultCode == constant.SUCCESS) {
            this.$message({
              message: res.data.resultMsg,
              type: "success",
              duration: 1500,
              onClose: () => {
                this.getList();
              },
            });
          } else {
            this.$message({
              message: res.data.resultMsg,
              type: "error",
              duration: 1500,
              onClose: () => { },
            });
          }
        })
        .catch((err) => {
          this.$store.dispatch("loading/CHANGE_LOADING", false);
        });
    },
    checkClash(data) {
      checkClash(data)
        .then((res) => {
          this.$store.dispatch("loading/CHANGE_LOADING", false);
          if (res.data.resultCode == constant.SUCCESS) {
          } else {
            this.$message({
              message: res.data.resultMsg,
              type: "error",
              duration: 1500,
              onClose: () => {
                this.addVisible = false;
              },
            });
          }
        })
        .catch((err) => {
          this.$store.dispatch("loading/CHANGE_LOADING", false);
        });
    },
    toogleExpandRule(row) {
      this.tabDialog = 2;
    },

    // 清除查询条件
    resetSearch() {
      // this.searchParams.flowName = "";
      // this.searchParams.publishBegDate = "";
      // this.searchParams.publishEndDate = "";
      // this.searchParams.auditStatus = "";
      // this.searchParams.publishUser = "";
      // this.searchParams.taskNo = "";

      this.searchParams.demandNo = "";
      this.searchParams.demandDesc = "";
      this.searchParams.status = "";
    },
    dateFormat(row, column) {
      return constant.dateFormat("YYYY-mm-dd", row.taskStartTime);
    },
    // 每页数
    sizeChangeHandle(val) {
      this.paginations.pageSize = val;
      // this.paginations.pageIndex = 1;
      this.getList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.paginations.pageIndex = val;
      this.getList();
    },
  },
  watch: {},
  computed: {},
  filters: {
    statusFormat: function (value) {
      return constant.getLabel(value, constant.status);
    },
    taskLevelFormat: function (value) {
      return constant.getLabel(value, constant.taskLevel);
    },
    flagFormat: function (value) {
      return constant.getLabel(value, constant.judge);
    },
    // 是否冲突
    isClashFormat: function (value) {
      return constant.getLabel(value, constant.isClash);
    },
    auditStatusFormat: function (value) {
      return constant.getLabel(value, constant.auditStatus);
    },
    isEffectFormat: function (value) {
      return constant.getLabel(value, constant.ruleConfig.isEffects);
    },
    clashDivisorFormat: function (value) {
      return constant.getLabel(value, constant.clashDivisor);
    },
  },
};
</script>

<style lang="less" scoped>
.fillcontain {
  padding-bottom: 0;

  .fastQuery {
    padding: 15px 20px 10px 20px;
    background: #fff;
    border-bottom: 1px solid #e1e1e1;

    .fastQuery_title {
      color: #666;
      padding: 6px 0px;
    }

    .fastQuery_item {
      margin: 0 10px;
    }

    .item_default {
      .el-button {
        color: #409eff !important;
        border-color: #c6e2ff !important;
        background-color: #ecf5ff !important;
      }
    }

    .moreCondition {
      color: #68a3fc;
      cursor: pointer;
      padding: 6px 0px;

      .el-icon-d-arrow-right {
        transform: rotate(90deg);
      }

      .el-icon-d-arrow-left {
        transform: rotate(-90deg);
      }
    }
  }
}

.contain {
  background: #fff;
  padding: 10px;
  margin-bottom: 20px;
}

.pagination {
  padding: 10px 20px;
  text-align: right;
}

.operationIcon {
  // padding: 12px;
  border: 1px solid #e5e5e5;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-block;
  cursor: pointer;
  box-shadow: 0 0 3px #f9f9f9;

  .svg-icon {
    font-size: 14px;
    fill: #68a3fc;
  }
}

.search_container {
  padding: 0px 20px 0 20px;
}

.el-dropdown {
  vertical-align: top;
}

.el-dropdown + .el-dropdown {
  margin-left: 15px;
}

.el-icon-arrow-down {
  font-size: 12px;
}
</style>
<style lang="less">
.colorred {
  color: red !important;
}
</style>



